package com.zhiyun.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author zc
 * @Date 2025/4/28 上午11:16
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    @Serial
    private static final long serialVersionUID = 3588836013273496029L;
    private int code;
    private String msg;
    private Object obj;
    public static Result ok(String msg,Object obj){
        Result result = new Result();
        result.setCode(200);
        result.setMsg(msg);
        result.setObj(obj);
        return result;
    }
    public static Result ok(Object obj){
        Result result = new Result();
        result.setCode(200);
        result.setMsg("成功");
        result.setObj(obj);
        return result;
    }
    public static Result okMsg(String msg){
        Result result = new Result();
        result.setCode(200);
        result.setMsg(msg);
        return result;
    }
    public static Result fail(String msg,Object obj){
        Result result = new Result();
        result.setCode(500);
        result.setMsg(msg);
        result.setObj(obj);
        return result;
    }
    public static Result fail(String msg){
        Result result = new Result();
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }
}
